﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Runtime.Serialization;

namespace Common.DataBaseNew
{
    class InitData
    {
        public static DBmediator initForumData()
        {
            DateTime d1 = DateTime.Now;
            DBmediator db = new DBmediator();
            //מנהל על
            User Gilad = db.getDirector();
            //מנהל
            User Ilya = new User("Ilya", "Sonin", "Sonini", 111, "bla1@bla.com");
            db.addForum("Forum1", Ilya); //id = 1

            db.addSubForum(1, "Games");  //id = 1
            db.addSubForum(1, "Movies"); //id = 2

            db.addSubForumModerator(1, 1, "Ilya");

            db.registerUser(1, "Natalya", "Safro", "Natali", 100, "bla2@bla.com");
            User Natalya = db.getUser(1, "Natalya");
            db.addSubForumModerator(1, 2, "Natalya");

            User Moti = new User("Moti", "Moti", "Elishay ", 222, "bla3@bla.com");
            User Zach = new User("Zach", "Zach", "Laniado", 333, "bla4@bla.com");
            db.registerUser(1, Moti);
            db.registerUser(1, Zach);

            db.addThread(1, 1, "Fifa", "Sport game", Ilya);  // id = 1
            db.addThread(1, 1, "IgI", "Computer game", Natalya);  //id = 2
            db.addThread(1, 2, "Titanic", "Boring movie", Moti); //id = 1
            db.addThread(1, 2, "Matrix", "Owsom movie!!!", Zach); //id = 2

            db.addPost(1, 1, 1, "Love it", "Very good game...", Gilad);
            db.addPost(1, 1, 1, "Hate it", "Very bad game...", Ilya);
            db.addPost(1, 1, 2, "nice game", "Very good game...", Natalya);
            db.addPost(1, 1, 2, "fichsa game", "Very bad game...", Moti);
            db.addPost(1, 2, 1, "Love it", "Very good movie...", Zach);
            db.addPost(1, 2, 2, "Hate it", "Very bad movie...", Gilad);

            /*
                Console.WriteLine(db.getForum(1).getTitle().Equals("Forum1"));
                Console.WriteLine(db.getDirector().getUserName().Equals("Gilad"));
                Console.WriteLine(db.containsUser(1, "Gilad"));
                Console.WriteLine(db.containsUser(1, "Ilya"));
                Console.WriteLine(db.containsUser(1, "Natalya"));
                Console.WriteLine(db.containsUser(1, "Moti"));
                Console.WriteLine(db.containsUser(1, "Zach"));
                Console.WriteLine(db.getForumAdmin(1).getUserName().Equals("Ilya"));
                Console.WriteLine(db.isSubForumModerator(1, 1, "Ilya"));
                Console.WriteLine(db.isSubForumModerator(1, 1, "Gilad"));  //false
                Console.WriteLine(db.isSubForumModerator(1, 2, "Natalya"));
                Console.WriteLine(db.isSubForumModerator(1, 1, Ilya));
                Console.WriteLine(db.isSubForumModerator(1, 2, Natalya));

                Console.WriteLine();
                Console.WriteLine(db.getForum(1).getTitle());
                Console.WriteLine(db.dataBasetoString().ElementAt(0).Key);
                Console.WriteLine(db.dataBasetoString().ElementAt(0).Value);
                Console.WriteLine(db.dataBasetoString().Count);
                Console.WriteLine();

                Console.WriteLine(db.forumToString(1).ElementAt(0).Key);
                Console.WriteLine(db.forumToString(1).ElementAt(0).Value);
                Console.WriteLine(db.forumToString(1).ElementAt(1).Key);
                Console.WriteLine(db.forumToString(1).ElementAt(1).Value);
                Console.WriteLine(db.forumToString(1).Count);
                Console.WriteLine();

                Console.WriteLine(db.subForumToString(1, 1).ElementAt(0).Value);
                Console.WriteLine(db.subForumToString(1, 1).ElementAt(1).Value);
                Console.WriteLine(db.subForumToString(1, 2).ElementAt(0).Value);
                Console.WriteLine(db.subForumToString(1, 2).ElementAt(1).Value);
                Console.WriteLine();

                Console.WriteLine(db.threadToString(1, 1, 1).ElementAt(0).Value);
                Console.WriteLine(db.threadToString(1, 1, 1).ElementAt(1).Value);
                Console.WriteLine(db.threadToString(1, 1, 1).ElementAt(2).Value);
                Console.WriteLine();

                Console.WriteLine(db.threadToString(1, 1, 2).ElementAt(0).Value);
                Console.WriteLine(db.threadToString(1, 1, 2).ElementAt(1).Value);
                Console.WriteLine(db.threadToString(1, 1, 2).ElementAt(2).Value);
                Console.WriteLine();

                Console.WriteLine(db.threadToString(1, 2, 1).ElementAt(0).Value);
                Console.WriteLine(db.threadToString(1, 2, 1).ElementAt(1).Value);
                Console.WriteLine();

                Console.WriteLine(db.threadToString(1, 2, 2).ElementAt(0).Value);
                Console.WriteLine(db.threadToString(1, 2, 2).ElementAt(1).Value);
                Console.WriteLine();

                db.complaint(1, 1, "Ilya");
                db.complaint(1, 2, "Natalya");
                db.complaint(1, 1, "Ilya");
                db.complaint(1, 2, "Natalya");
                db.complaint(1, 1, "Ilya");
                db.complaint(1, 2, "Natalya");
                db.complaint(1, 1, "Ilya");
                db.complaint(1, 2, "Natalya");
                db.complaint(1, 1, "Ilya");
                db.complaint(1, 2, "Natalya");
                db.complaint(1, 1, "Ilya");
                db.complaint(1, 2, "Natalya");


                Console.WriteLine(db.getModeratorComplaints(1, 1, Ilya));
                Console.WriteLine(db.getModeratorComplaints(1, 2, Natalya));
                Console.WriteLine(db.getModeratorComplaints(1, 1, "Ilya"));
                Console.WriteLine(db.getModeratorComplaints(1, 2, "Natalya"));

                Console.WriteLine(db.isSubForumModerator(1, 1, "Ilya"));
                Console.WriteLine(db.isSubForumModerator(1, 2, "Natalya"));

                Console.WriteLine(db.removeSubForum(1, 1));

                DateTime d2 = DateTime.Today;
                Console.WriteLine(d1);
                Console.WriteLine(d2);
                Console.WriteLine((d1 - d2).Minutes);


                Console.Read();
                */

            return db;
        }
    }

}